<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld"%>
<!DOCTYPE html>
<html>
	<head>
		<title>修改密码</title>
		<!-- 引入公用Js与Css -->
  		<%@include file="/view/common/resource.jsp" %>
	</head>
	<body>
		<div id="wrap">
			
			<div class="clearfix mt10 mr10 ml10">
				<form id="pwdForm" class="form-horizontal" action="<%=basePath%>/changePwdSave" method="post">
					<dl class="ml50 mt10 pb50">
						<dd class="clearfix pt10">
							<label class="w100 pull-left text-right line-height30">旧密码:</label>
							<div class="pull-left ml10 w200 radius3 borderC input_div pl5">
								<input type="password" id="oldPwd" name="oldPwd" class="bg_none border_none"    title="请输入旧密码"/>
							</div>
							<p class="pull-left ml5 line-height30 color_red">*</p>
						</dd>
						
						<dd class="clearfix pt10">
							<label class="w100 pull-left text-right line-height30">新密码:</label>
							<div class="pull-left ml10 w200 radius3 borderC input_div pl5">
								<input type="password" id="newPwd" name="newPwd" class="bg_none border_none"    title="请输入新密码"/>
							</div>
							<p class="pull-left ml5 line-height30 color_red">*</p>
						</dd>
						
						<dd class="clearfix pt10">
							<label class="w100 pull-left text-right line-height30">重复新密码:</label>
							<div class="pull-left ml10 w200 radius3 borderC input_div pl5">
								<input type="password" id="againPWd" name="againPWd" class="bg_none border_none"    title="请再次输入新密码"/>
							</div>
							<p class="pull-left ml5 line-height30 color_red">*</p>
						</dd>
						<dd class="clearfix pt30 ml110">
							<p class="radius3 bg_blue text-center w200 line-height30 mt10">
								<a href="javascript:" onclick="addSave();" class="color_white show">确认修改</a>
							</p>
						</dd>
					</dl>
				</form>
			</div>
		</div>
		<script type="text/javascript">
	    var validate = null;
	    $(document).ready(function(){
	    	validate = $('#pwdForm').validate({
				rules:{
					oldPwd:{
						required:true
					},
					newPwd:{
						required:true,
						lettersOrNumbers:true,
						minlength:6,
						maxlength:20
					},
					againPWd:{
						required:true,
						equalTo:"#newPwd"
					}
				},
				messages:{
					oldPwd:{
						required:"请输入旧密码"
					},
					newPwd:{
						required:"请输入新密码",
						lettersOrNumbers:"密码是由6-20位数字、字母组成",
						minlength:"密码是由6-20位数字、字母组成",
						maxlength:"密码是由6-20位数字、字母组成"
					},
					againPWd:{
						required:"请再次输入新密码",
						equalTo:"您两次输入的密码不一致"
					}
				},
				errorPlacement: function(error, element) {
				    error.appendTo(element.parent().parent());
				}
			});
	    });
	    
    	/* 数据保存 */
	    function addSave() {
    		
    		// 验证数据
	    	if (!validate.form()) {
	    		return false;
	    	}
	    	
    	    var actionurl=$('#pwdForm').attr('action');//提交路径
    	    
    	    $("#pwdForm").ajaxSubmit({
    	    	type:"post",
    	    	url:actionurl,
    	    	dataType: "json",
    	    	success:function(data){
        	    	if (data.success) {
    	   	        	// 成功后跳转首页
    	   	            layer.msg("密码修改成功", {icon: 6, time:1500}, function() {
    	   	            	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    	   	            	parent.layer.close(index);
    	   	            });
    	   	        } else {
    	   	      		// 失败提醒
    	   	        	layer.msg(data.msg, {icon: 5, time:1500});
    	   	        }
       	    	}
    	    }); 
	    }
    </script>
	</body>
</html>
